/**
 * @param {string} s
 * @return {number}
 */
var minLength = function (s) {
  while(s.indexOf('AB') || s.indexOf('CD')){
   s= s.replace('AB','')
     s.replace('CD','')

  }
  return s.length
};

minLength('ABFCACDB')